home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 14 / 014.d81 / pps #32 < prev    next >
Text File  |  2022-08-26  |  2KB  |  120 lines

  1.  
  2. ======================================
  3.    Peeks, Pokes, & SYSes -- Part 32
  4.  
  5.        By James Germany Weiler
  6.           and Alien Gardner
  7. ======================================
  8.  
  9.  
  10.   When we bought our Commodore 64s, we
  11.  
  12. expected to be able to program
  13.  
  14. graphics.  We soon found that there
  15.  
  16. were plenty of programs that would
  17.  
  18. help us produce graphic images.  But
  19.  
  20. what we wanted was to make our own
  21.  
  22. programs use graphics.
  23.  
  24.   Well, PEEKs POKEs and SYSes last
  25.  
  26. touched on graphics in part 19, when
  27.  
  28. we showed you how to make and use
  29.  
  30. sprites.  Now we think it is time to
  31.  
  32. leap into the exciting world of
  33.  
  34. bit-mapped graphics.
  35.  
  36.   Sure, you're thinking that anything
  37.  
  38. with a name like "bit-mapped graphics"
  39.  
  40. will be a nightmare to use and under-
  41.  
  42. stand, and you're partly right.  But
  43.  
  44. what's PEEKs POKEs and SYSes for if
  45.  
  46. not to make plain even the most
  47.  
  48. arcane of programmers' tricks?
  49.  
  50.   So, we start simple:  What is a BIT?
  51.  
  52. That's easy!  A bit is the smallest,
  53.  
  54. most fundamental piece of memory in a
  55.  
  56. computer.  It contains only one piece
  57.  
  58. of information: a yes or a no; a true
  59.  
  60. or a false; an on or an off; a one or
  61.  
  62. a zero.
  63.  
  64.   We say a bit is SET if its value is
  65.  
  66. one and RESET if its value is zero.
  67.  
  68.   But computers don't keep information
  69.  
  70. in the form of pure bits.  They
  71.  
  72. assemble the bits into words and then
  73.  
  74. they store the words into memory.
  75.  
  76. Each memory word in the Commodore-64
  77.  
  78. is made up of eight bits. An eight bit
  79.  
  80. word is called a byte.
  81.  
  82.   The value of a byte depends on the
  83.  
  84. values of the bits that make it up.
  85.  
  86. Any bit that is a zero has a value
  87.  
  88. of zero.  Any bit that is a one has a
  89.  
  90. value that varies depending on the
  91.  
  92. bit's position in the byte.  The value
  93.  
  94. of a byte is equal to the sum of the
  95.  
  96. values of its bits.
  97.  
  98.     Bit Position    Bit value
  99.  
  100.           0         2^0 =   1
  101.           1         2^1 =   2
  102.           2         2^2 =   4
  103.           3         2^3 =   8
  104.           4         2^4 =  16
  105.           5         2^5 =  32
  106.           6         2^6 =  64
  107.           7         2^7 = 128
  108.  
  109. Some examples:
  110.  
  111.    bit:76543210
  112.        --------
  113. byte:  00000000   value:   0
  114. byte:  00010101   value:  21
  115. byte:  11111111   value: 255
  116. byte:  10011011   value: 155
  117.  
  118.  
  119. -------< continued in Part 33 >-------
  120.